﻿using System;
using System.Linq;

namespace Closures
{
    class Program
    {
        static Func<int> AddThree(int n)
        {
            return () => n + 3;
        }

        static void Main(string[] args)
        {
            // Simple closure
            var value = 5;
            Func<int, int> multiply = x => (x * x) + value;
            var mulResult = multiply(3);
            Console.WriteLine("Multiply value: {0}", mulResult);

            // Parameterized
            var addThree = AddThree(4);
            var addThreeResult = addThree();
            Console.WriteLine("Add Three Result: {0}", addThreeResult);
        }
    }
}
